from typing import List,Generic,TypeVar

T = TypeVar('T')

class Stack(Generic[T]):
    def __init__(self) -> None:
        self._container: List[T] = []

    def push(self, item: T) -> None:        
        self._container.append(item)

    def pop(self) -> T:
        return self._container.pop()

    def is_empty(self) -> bool:
        return len(self._container) == 0

    def size(self) -> int:
        return len(self._container)
    
    def __repr__(self) -> str:
        return repr(self._container)
    
num_disks = 3
tower_a = Stack[int]()
tower_b = Stack[int]()
tower_c = Stack[int]()

for i in range(num_disks):
    tower_a.push(i)


# print(tower_a)

def hanoi(begin:Stack[int], end:Stack[int], temp:Stack[int], n:int) -> None:
    if n == 1:
        print(f"Move disk {n} from {begin} to {end}",end=" ")
        end.push(begin.pop())
        print(f"result: {begin} to {end}")
    else:
        hanoi(begin, temp, end, n-1)
        hanoi(begin, end, temp, 1)
        hanoi(temp, end, begin, n-1)

if __name__ == '__main__':
    print(tower_a)
    print(tower_b)
    print(tower_c)
    hanoi(tower_a, tower_c, tower_b, num_disks)
    print(tower_a)
    print(tower_b)
    print(tower_c)
    pass 
